package it.poste.il.compensatore.utilities;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * Class that extends Logger.
 */
public class LoggerCompensatore
{

	
	// logger instance
	private Logger logger = null;

	/**
	 * Take the Logger.
	 * @param o The class in use.
	 * @return Logger The logger.
	 */
	public LoggerCompensatore(String str) {
		Properties properties = new Properties();
		InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("/log4j.properties");
		try {
			properties.load(inputStream);
		} catch (IOException e) {
			e.printStackTrace();
		} 
		this.logger = Logger.getLogger(str);
		PropertyConfigurator.configure(properties);
	}


	/**
	 * Take the logger.
	 * @param o The class in use.
	 * @return LoggerCompensatore The logger to return.
	 */
	public LoggerCompensatore getLogger(Object o) {
		logger.getLogger(o.getClass());
		return this;
	}
	
	/**
	 * Create the message for alignment to log.
	 * @param msg The message to log.
	 * @return void
	 */
	public void insertAlignment (String msg) {
	    info("ALIGNMENT - Message: " + msg);
	}

	/**
	 * Create the message for cancellation to log.
	 * @param msg The message to log.
	 * @return void
	 */
	public void insertCancellation (String msg) {
	    info("CANCELLATION - Message: " + msg);
	}

	/**
	 * Create the message for normal to log.
	 * @param msg The message to log.
	 * @return void
	 */
	public void insertNormal (String msg) {
	    info("NORMAL - Message: " + msg);
	}
	public void info(String msg) {
		// TODO Auto-generated method stub
		logger.info(msg);
	}
	public void error(String msg) {
		// TODO Auto-generated method stub
		logger.error(msg);

	}
	public void debug(String msg) {
		// TODO Auto-generated method stub
		logger.debug(msg);

	}
}